LEADTOOLS PDF (Leadtools.Pdf assembly)
LEAD Technologies, Inc

MergeWith(String[],String) Method

Example 





An array of System.String's that contain the names of the source files to merge with this PDFFile. Must not be null (Nothing in Visual Basic) and must contain at least one item and a maximum of 100 items.
Name of the destination PDF file to be created. If the value of this parameter is null (Nothing in Visual Basic) then the file name set in FileName will be updated.
Merges this PDF file with one or more PDF existing files.
Syntax
public void MergeWith( 
   string[] sourceFileNames,
   string destinationFileName
)
'Declaration
 
Public Overloads Sub MergeWith( _
   ByVal sourceFileNames() As String, _
   ByVal destinationFileName As String _
) 
'Usage
 
Dim instance As PDFFile
Dim sourceFileNames() As String
Dim destinationFileName As String
 
instance.MergeWith(sourceFileNames, destinationFileName)
public void MergeWith( 
   string[] sourceFileNames,
   string destinationFileName
)
 function Leadtools.Pdf.PDFFile.MergeWith(String[],String)( 
   sourceFileNames ,
   destinationFileName 
)
public:
void MergeWith( 
   array<String^>^ sourceFileNames,
   String^ destinationFileName
) 

Parameters

sourceFileNames
An array of System.String's that contain the names of the source files to merge with this PDFFile. Must not be null (Nothing in Visual Basic) and must contain at least one item and a maximum of 100 items.
destinationFileName
Name of the destination PDF file to be created. If the value of this parameter is null (Nothing in Visual Basic) then the file name set in FileName will be updated.
Remarks

This method will merge two or more existing PDF files to form a new file containing all the pages from the pre-existing PDF files. The new file will be constructed as follows:

All the PDF files must pre-exist on disk and must be valid. The sourceFileNames parameter must not contain any null items.

To use this method, associate this PDFFile object with a valid PDF file and optional password. You can achieve this by either using the PDFFile(string fileName) or PDFFile(string fileName, string password) constructurs or set the file name and optional password directly into the FileName and Password properties. You do not need to call Load before using this method.

This method will use the following properties of this PDFFile object:

If one or more of the files to merge with are encrypted with a password, then use the MergeWith(PDFFile[] sourceFiles, string destinationFileName) version of this method that allow you to pass a list of PDFFile objects instead of just the file names, and thus, associated each input item with an optional password.

Example
 
Public Sub PDFFileMergeWithExample()
      Dim sourceFileName1 As String = Path.Combine(LEAD_VARS.ImagesDir, "File1.pdf")
      Dim sourceFileName2 As String = Path.Combine(LEAD_VARS.ImagesDir, "File2.pdf")
      Dim sourceFileName3 As String = Path.Combine(LEAD_VARS.ImagesDir, "File3.pdf")

      Dim destinationFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Merged.pdf")

      ' Merge 1 with (2, 3) and form destination
      Dim pdfFileObj As New PDFFile(sourceFileName1)
      pdfFileObj.MergeWith(New String() {sourceFileName2, sourceFileName2}, destinationFileName)
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void PDFFileMergeWithExample()
   {
      string sourceFileName1 = Path.Combine(LEAD_VARS.ImagesDir, @"File1.pdf");
      string sourceFileName2 = Path.Combine(LEAD_VARS.ImagesDir, @"File2.pdf");
      string sourceFileName3 = Path.Combine(LEAD_VARS.ImagesDir, @"File3.pdf");

      string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Merged.pdf");

      // Merge 1 with (2, 3) and form destination
      PDFFile pdfFile = new PDFFile(sourceFileName1);
      pdfFile.MergeWith(new string[] { sourceFileName2, sourceFileName2 }, destinationFileName);
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PDFFile Class
PDFFile Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.